<?php

namespace App\Http\Controllers\Admin;

use App\Events\Event;
use App\Events\MailEvent;
use App\Http\Controllers\Controller;
use App\Http\Service\Admin\IndexService;
use App\Jobs\SendReminderEmail;
use Common\Service\RedisService;

use Illuminate\Support\Facades\Redis;

class IndexController extends Controller
{
    /**
     * 后台公共部分
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        //队列
        //$result = Redis::flushall();dd();
        /*$res = SendReminderEmail::dispatch('wwww@qq.com')->delay(3);
        dd($res);*/

        //事件监听
        /*$email = ['title' => '邮件标题', 'mailbox' => '1786368599@qq.com', 'content' => '邮件内容'];
        $res = event(new \App\Events\SendMailEvent($email));
        die($res);*/

        //测试redis-队列
        /*$result = RedisService::rpush('mall','1786368599@qq.com');
        dd($result);*/

        //后台登录管用户信息
        $admin = admin_info();

        //获取菜单列表
        $menu = IndexService::getMenuList($admin['id']);
        //dd($menu);

        return view('admin.layout.layout', ['admin' => $admin, 'menu' => $menu]);
    }

    /**
     * 主页统计部分
     */
    public function statistics()
    {
        $data = IndexService::statistics();

        return view('admin.layout.index', $data['data']);
    }
}